#!/usr/bin/env python
"multiprocessing.Pool类"

import os
from multiprocessing import Pool


def powers(x):
	'返回2的x次方'
	# print('\n\t@' + str(os.getpid()), x)  # 能够监视子进程
	return 2 ** x


def main():
	workers_pool = Pool(processes=5)
	results_list = workers_pool.map(powers, [2] * 100)
	print(results_list[:16])
	print(results_list[-2:])

	results_list = workers_pool.map(powers, list(range(1, 101)))
	print(results_list[:16])
	print(results_list[-2:])


if __name__ == '__main__':
	main()
